<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:g="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Banner" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="banner" />
	</ui:define>

	<ui:define name="content">

		<center>
			<h:form>
				<p:panel header="Gestione Banner">

					<h:panelGrid columns="2" style="width: 95%">
						<h:outputLabel for="name" value="Nome (*):" style="width: 100%;" />
						<h:inputText id="name" value="#{bannerController.element.name}"
							style="width: 100%;" />

						<h:outputLabel for="url" value="Url (*):" style="width: 100%;" />
						<h:inputText id="url" value="#{bannerController.element.url}"
							style="width: 100%;" />

						<h:outputLabel for="internal" value="Interno (*):"
							style="width: 100%;" />
						<p:selectOneRadio id="internal"
							value="#{bannerController.element.internal}">
							<f:selectItem itemLabel="si" itemValue="true" />
							<f:selectItem itemLabel="no" itemValue="false" />
						</p:selectOneRadio>

						<h:outputLabel value="Tipologia(*):" for="bannerTypologyId" />
						<h:selectOneMenu id="bannerTypologyId" style="width: 100%;"
							value="#{bannerController.element.bannerTypology.id}"
							required="true">
							<f:selectItems value="#{bannerTypologyItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="description" value="Descrizione:" />
						<h:inputTextarea id="description" cols="20" rows="20"
							value="#{bannerController.element.description}"
							style=" height : 166px; width: 100%;" />

						<h:outputLabel value="Immagine:" for="image"
							rendered="#{not empty bannerController.element.image}" />
						<h:graphicImage id="image"
							value="/img/#{bannerController.element.image.filename}"
							alt="#{bannerController.element.image.filename}"
							title="#{bannerController.element.image.filename}"
							style="padding: 5px;"
							rendered="#{not empty bannerController.element.image}" />
					</h:panelGrid>
					<br />
				</p:panel>

				<h:panelGrid columns="5">

					<h:commandButton action="#{bannerController.save}" value="Salva"
						immediate="false" rendered="#{not bannerController.editMode}" />

					<h:commandButton action="#{bannerController.saveAndModifyImage}"
						value="Salva e Modifica Immagine" immediate="false"
						rendered="#{not bannerController.editMode}" />

					<h:commandButton action="#{bannerController.update}"
						value="Salva le modifiche" immediate="false"
						rendered="#{bannerController.editMode}" />

					<h:commandButton action="#{bannerController.updateAndModifyImage}"
						value="Salva le modifiche e Modifica Immagine" immediate="false"
						rendered="#{bannerController.editMode}" />

					<h:commandButton action="#{bannerController.delete}"
						value="Elimina" rendered="#{bannerController.editMode}"
						immediate="true"
						onclick="if (!confirm('Vuoi davvero eliminare?')) return false" />
				</h:panelGrid>
			</h:form>
		</center>


	</ui:define>
</ui:composition>